async function addActivity(activity) {

}

async function getActivityList(data) {
  const { pageNumber ,pageSize } = data
  if (!pageNumber) {
    return {
      code: 500,
      msg: '请输入页数',
      data: null
    }
  }else if (!pageSize) {
    return {
      code: 500,
      msg: '请输入条数',
      data: null
    }
  }else {
    const offset = ( Number(data.pageNumber) - 1) * 10;
    const pageSizeNum = Number(data.pageSize)
    let selectSql = `SELECT * FROM activity ORDER BY updateTime ASC LIMIT ? OFFSET ? `;
    const qlParams = [ pageSizeNum , offset];
    const selectRows = await global.sql(selectSql, qlParams)
    if (selectRows.status) {
      return {
        code: 200,
        msg: '请求成功',
        data: selectRows.data
      }
    }else {
      return {
        code: 500,
        msg: '服务繁忙',
        data: null
      }
    }
  }
}

async function getMyActivity(data) {
  const offset = (data.pageNumber - 1) * 10;
  let selectSql = `SELECT * FROM participantsforactivity WHERE userId = ${data.userId} OR createById = ${data.userId} ORDER BY createTime ASC LIMIT ? OFFSET ?`;
  const qlParams = [ 10, offset];
  let selectRows = await global.sql(selectSql, qlParams)
  if (selectRows.status) {
    return {
      code: 200,
      msg: '请求成功',
      data: selectRows.data
    }
  }else {
    return {
      code: 500,
      msg: '服务繁忙',
      data:  null
    }
  }
}

exports.addActivity = addActivity
exports.getActivityList = getActivityList
exports.getMyActivity = getMyActivity
